home *** CD-ROM | disk | FTP | other *** search
- 'These Functions need to be loaded with the BFUNCS libary
- 'BFUNCS.LIB for compile time. BFUNCS.QLB for QBX time.
- '$INCLUDE: 'nicehdr'
-
- DEFINT A-Z
- DEFINT A-Z
- FUNCTION Blanks% (Strig$)
-
- '----------------------------------------------------------
- 'Function that returns a boolean value of true if the string consists
- 'entirely of spaces and null characters; otherwise false.
- '----------------------------------------------------------
-
- LENGTH = LEN(Strig$)
- FOR X = 1 TO LENGTH
- CH$ = MID$(Strig$, X, 1)
- IF ASC(CH$) <> 0 AND ASC(CH$) <> 32 THEN Blanks = 0: EXIT FUNCTION
- NEXT X
- Blanks = -1
-
- END FUNCTION
-
- DEFSNG A-Z
- DEFINT A-Z
- DEFINT A-Z
- FUNCTION CheckSum (NUM$)
-
- 'checks NUM$ with a funky mathematical algorithm that all valid invitation,
- 'account, and reference numbers fit into. Returns true for valid false if not.
-
- RETCODE = -1
- RESULT = 0
- FOR l = 1 TO (LEN(NUM$) - 1)
- IF LEN(NUM$) MOD 2 = 1 THEN
- MULT = 2 - (l MOD 2)
- ELSE
- MULT = 1 + (l MOD 2)
- END IF
-
- DIG = VAL(MID$(NUM$, l, 1))
-
- DIG = DIG * MULT
- IF DIG > 9 THEN
- DIG = 1 + (DIG MOD 10)
- END IF
-
- RESULT = RESULT + DIG
- NEXT l
- RESULT = (10 - (RESULT MOD 10)) MOD 10
-
- DIG = VAL(RIGHT$(NUM$, 1))
-
- IF (DIG <> RESULT) THEN
- RETCODE = 0
- END IF
-
- CheckSum = RETCODE
- END FUNCTION
-
- DEFSNG A-Z
- DEFINT A-Z
- DEFINT A-Z
- SUB Enterinfo (ROW, COL, LENGTH, COLR1, COLR2, Data$, MODE, SHOW, VKEY$, RET)
-
- 'This subroutine is for entering a designated length of data from
- 'the keyboard.
-
- '----VARIABLE-----------------------DESCRIPTION------------------------
- ' ROW% ;ROW TO START ENTERING INFORMATION
- ' COL% ;COLUMN TO START ENTERING INFORMATION
- ' LENGTH% ;MAX LENGTH OF DATA TO BE ENTERED
- ' COLR1% ;FOREGROUND COLOR
- ' COLR2% ;BACKGROUND COLOR
- ' DATA$ ;VARIABLE THE ENTRY IS STORED IN
- '
- ' MODE% ;0 = ENTER
- ' ;1 = EDIT WITH CURSOR AT THE END OF THE DATA FIELD
- ' ;2 = EDIT WITH CURSOR AT THE BEGINNING OF THE FIELD
- ' ;3 = DISPLAY THE DATA FIELD
- ' ;4 = CLEAR THE DATA FIELD
- '
- ' SHOW% ;0 = DOTS (DEF)
- ' ;1 = BLANKS
- ' ;2 = UNDERSCORE
- ' ;3 = NO SHOW
- '
- ' VKEY$ = "XXX" ;3 CHAR INPUT -- ONLY VALID IN ENTER AND EDIT MODES
- ' ;CHAR 1 -- P = ALLOW PFKEY USE
- ' ;CHAR 2 -- A = ALLOW UP AND DOWN ARROW USE
- ' ;CHAR 3 -- T = ALLOW TAB AND BACKTAB EXIT FROM SUB
- ' ;ALL CH -- N = DO NOT ALLOW USE OF KEY (DEF)
- '
- ' RET% INPUT
- ' ;0 = NON-DESTRUCTIVE ENTER KEY IN EDIT MODE (DEF)
- ' ;1 = DESTRUCTIVE ENTER KEY IN EDIT MODE
- ' OUTPUT -- NOT USED IN DISPLAY OR CLEAR MODE
- ' ;0 = ENTER KEY PRESSED OR FIELD FILLED
- ' ;1-9 = PF KEY PRESSED
- ' ;10 = ESC KEY
- ' ;11 = UP ARROW
- ' ;12 = DOWN ARROW
- ' ;13 = TAB
- ' ;14 = BACKTAB
- '
- '------------------------------------------------------------------------------
-
- '-------- SET INITIAL CONDITIONS ------------
- CURSORX = 0
- COLOR COLR1, COLR2
- LOCATE ROW, COL + CURSORX
-
- IF MODE = 0 OR MODE = 4 THEN 'If enter or clear mode
- Data$ = SPACE$(LENGTH) 'clear data
- IF SHOW = 1 THEN 'and show _ . or " "
- PRINT SPACE$(LENGTH)
- ELSEIF SHOW = 2 THEN
- PRINT STRING$(LENGTH, "_")
- ELSEIF SHOW <> 3 THEN
- PRINT STRING$(LENGTH, ".")
- END IF
- END IF
-
- IF (MODE = 1 OR MODE = 2) AND RET = 1 THEN
- RETRN = 1 'set return type
- ELSE
- RETRN = 0
- END IF
- RET = 0
-
- Data$ = LEFT$(Data$, LENGTH) 'cut off excess data
- IF LEN(Data$) < LENGTH THEN 'pad with spaces
- Data$ = Data$ + SPACE$(LENGTH - LEN(Data$))
- END IF
- IF MODE >= 1 AND MODE <= 3 THEN PRINT Data$
-
- IF MODE = 3 OR MODE = 4 THEN GOTO EXITSUB
-
- PFKEY = 0: ARROW = 0: TABKEY = 0
- VKEYLEN = LEN(VKEY$) 'set VKEY$ variables
- IF VKEYLEN > 0 AND MID$(VKEY$, 1, 1) = "P" THEN PFKEY = -1
- IF VKEYLEN > 1 AND MID$(VKEY$, 2, 1) = "A" THEN ARROW = -1
- IF VKEYLEN > 2 AND MID$(VKEY$, 3, 1) = "T" THEN TABKEY = -1
-
- Data$ = RTRIM$(Data$)
- LENDATA = LEN(Data$)
- IF MODE = 1 AND LENDATA < LENGTH THEN
- CURSORX = LENDATA 'put cursor at end of field for mode 1
- ELSEIF MODE = 1 THEN
- CURSORX = LENGTH - 1
- END IF
-
- '----------- MAIN LOOP ---------
- DO
- MOVEX = 0
-
- IF LEN(Data$) < LENGTH THEN
- Data$ = Data$ + SPACE$(LENGTH - LEN(Data$))
- END IF
- UNDERCURSOR$ = MID$(Data$, CURSORX + 1, 1)
-
- ' ---------- PRINT CURSOR ----------
- LOCATE ROW, COL + CURSORX
- COLOR COLR2, COLR1
- PRINT UNDERCURSOR$
-
- ' ---------- GET INPUT -----------
- a$ = ""
- WHILE a$ = ""
- a$ = INKEY$
- WEND
- a = ASC(RIGHT$(a$, 1)) + 256 * (LEN(a$) - 1)
-
- SELECT CASE a
- CASE 27 'esc key
- RET = 10
- GOTO EXITSUB
- CASE 13 'enter key
- EXITSUB: LOCATE ROW, COL + CURSORX
- COLOR COLR1, COLR2 'print cursor
- PRINT UNDERCURSOR$
-
- IF (RETRN = 1 OR MODE = 0) AND CURSORX + 1 <> LENGTH THEN
- LOCATE ROW, COL + CURSORX 'destructive enter
- PRINT SPACE$(LENGTH - CURSORX)
- MID$(Data$, CURSORX + 1, LENGTH - CURSORX) = SPACE$(LENGTH - CURSORX)
- END IF
- EXIT SUB
- CASE 8 'bs key
- UNDERCURSOR$ = " ": MOVEX = -1
- CASE 9 'tab key
- IF TABKEY THEN
- RET = 13
- GOTO EXITSUB
- ELSE
- MOVEX = 5
- END IF
- CASE 32 TO 255 'valid character
- UNDERCURSOR$ = a$: MOVEX = 1
- CASE 315 TO 324 'PF KEY
- IF PFKEY THEN RET = a - 314: GOTO EXITSUB
- CASE 327 'home key
- MOVEX = -CURSORX
- CASE 328 'up arrow
- IF ARROW THEN RET = 11: GOTO EXITSUB
- CASE 336 'down arrow
- IF ARROW THEN RET = 12: GOTO EXITSUB
- CASE 335 'end key
- MOVEX = LEN(RTRIM$(Data$)) - CURSORX
- CASE 331 'left arrow
- MOVEX = -1
- CASE 333 'right arrow
- MOVEX = 1
- CASE 271 'backtab key
- IF TABKEY THEN
- RET = 14
- GOTO EXITSUB
- ELSE
- MOVEX = -5
- END IF
- END SELECT
-
-
- ' ---------- CLEAR CURSOR ----------
- LOCATE ROW, COL + CURSORX
- COLOR COLR1, COLR2
- PRINT UNDERCURSOR$
-
- a$ = LEFT$(Data$, CURSORX) + UNDERCURSOR$: IF CURSORX < LEN(Data$) THEN Data$ = a$ + RIGHT$(Data$, LEN(Data$) - CURSORX - 1)
- IF CURSORX + MOVEX > LENGTH - 1 AND a > 30 AND a < 256 GOTO EXITSUB
-
- IF CURSORX + MOVEX > LENGTH - 1 THEN MOVEX = 0
- IF CURSORX + MOVEX < 0 THEN MOVEX = 0
- CURSORX = CURSORX + MOVEX
- LOOP
-
- END SUB
-
- DEFSNG A-Z
- DEFINT A-Z
- DEFINT A-Z
- FUNCTION Fexists (File$)
- a$ = DIR$(File$)
- IF a$ <> "" THEN
- Fexists = -1
- ELSE
- Fexists = 0
- END IF
- END FUNCTION
-
- DEFSNG A-Z
- DEFINT A-Z
- DEFINT A-Z
- SUB Frame (options, cx, CY, CW, CL, cfor, cback, ARRAYSTART, BUFFER$())
- cwatt = cfor + cback * 16
- flag = 0
- mx = cx + CW / 2 - 1
- my = CY + CL / 2
-
- CHGMOD = 1
- tx = CHGMOD
- IF CW > 0 THEN
- ty# = CHGMOD * (CL / CW)
- ELSE
- ty# = 0
- END IF
- kw = 2 * INT(CW / 2) + 1
- x1 = mx
- x2 = mx
- sy1# = my
- sy2# = my
-
- WHILE (x1 > cx AND (options AND 4) = 4)
-
- x1 = x1 - tx
- x2 = x2 + tx
- sy1# = sy1# - ty#
- sy2# = sy2# + ty#
- IF sy1# > INT(sy1#) + .5 THEN
- y1 = INT(sy1#) + 1
- ELSE
- y1 = INT(sy1#)
- END IF
-
- IF sy2# > INT(sy2#) + .5 THEN
- y2 = INT(sy2#) + 1
- ELSE
- y2 = INT(sy2#)
- END IF
-
- tw = x2 - x1 - 1
-
- GOSUB PrintFrame
- WEND
-
- flag = 1
- x1 = cx
- y1 = CY
- x2 = x1 + CW + 1
- y2 = y1 + CL + 1
- tw = CW
- kw = CW
-
- PrintFrame:
- CALL PUTSTRNG(x1, y1, 1, cwatt, CHR$(201))
- CALL PUTSTRNG(x1, y2, 1, cwatt, CHR$(200))
- CALL PUTSTRNG(x2, y1, 1, cwatt, CHR$(187))
- CALL PUTSTRNG(x2, y2, 1, cwatt, CHR$(188))
-
- CALL PUTSTRNG(x1 + 1, y1, tw, cwatt, STRING$(tw, 205))
- CALL PUTSTRNG(x1 + 1, y2, tw, cwatt, STRING$(tw, 205))
- FOR i = y1 + 1 TO y2 - 1
-
- IF tw < kw THEN
- li$ = MID$(BUFFER$(ARRAYSTART + i - y1 - 1) + SPACE$(kw), (kw - tw) / 2, tw)
- ELSE
- li$ = LEFT$(BUFFER$(ARRAYSTART + i - y1 - 1) + SPACE$(kw), kw)
- END IF
-
- IF flag = 1 AND (options AND 1) = 1 THEN
- BUFFER$(ARRAYSTART + i - y1 - 1) = ""
- END IF
- CALL PUTSTRNG(x1, i, tw + 2, cwatt, CHR$(186) + li$ + CHR$(186))
- NEXT i
-
- IF (options AND 2) = 2 AND flag = 1 THEN
-
- CALL SAVESCRN(x1 - 1, y1 + 1, 1, y2 - y1, buf$)
- slen = LEN(buf$)
- FOR i = 1 TO slen STEP 2
- buf$ = LEFT$(buf$, i) + CHR$(8) + RIGHT$(buf$, slen - i - 1)
- NEXT i
- CALL RESTSCRN(x1 - 1, y1 + 1, 1, y2 - y1, buf$)
-
- CALL SAVESCRN(x1 - 1, y2 + 1, tw + 2, 1, buf$)
- slen = LEN(buf$)
- FOR i = 1 TO slen STEP 2
- buf$ = LEFT$(buf$, i) + CHR$(8) + RIGHT$(buf$, slen - i - 1)
- NEXT i
- CALL RESTSCRN(x1 - 1, y2 + 1, tw + 2, 1, buf$)
-
- END IF
- IF flag = 0 THEN RETURN
-
- END SUB
-
- DEFSNG A-Z
- DEFINT A-Z
- DEFINT A-Z
- SUB GetDate (CurrDate$)
-
- DIM MO$(12)
-
- MO$(1) = "January": MO$(2) = "February": MO$(3) = "March": MO$(4) = "April"
- MO$(5) = "May": MO$(6) = "June": MO$(7) = "July": MO$(8) = "August"
- MO$(9) = "September": MO$(10) = "October": MO$(11) = "November": MO$(12) = "December"
-
- 'Get the date.
- C$ = DATE$
- 'Use VAL to find the month from the string returned by DATE$.
- MONTH$ = MO$(VAL(C$))
- 'Get the day.
- DAY$ = MID$(C$, 4, 2)
- IF LEFT$(DAY$, 1) = "0" THEN DAY$ = RIGHT$(DAY$, 1)
- 'Get the year.
- YEAR$ = RIGHT$(C$, 4)
- CurrDate$ = MONTH$ + " " + DAY$ + ", " + YEAR$
-
- WindowBuffer$(1) = " The System Date is:"
- WindowBuffer$(2) = " " + CurrDate$
- WindowBuffer$(4) = " 1 Enter Another Date"
- WindowBuffer$(5) = " 2 Return to the Main Menu"
- WindowBuffer$(7) = " Press Any Key To Continue"
- CALL Frame(3, 24, 7, 35, 9, 7, 1, 0, WindowBuffer$())
- a$ = INPUT$(1)
- IF a$ = "2" THEN CurrDate$ = "EXIT"
- IF a$ <> "1" THEN EXIT SUB
-
- startit:
- NewClear 6, 0
- WindowBuffer$(1) = " ENTER THE DATE (MMDDYY)"
- WindowBuffer$(3) = " "
- CALL Frame(3, 16, 2, 48, 6, 3, 1, 0, WindowBuffer$())
-
- LOCATE 7, 36
- COLOR 3, 1
- INPUT ; "", DTE$
-
- GOSUB CHECKDATE: IF INVALID = 1 THEN BEEP: GOTO startit
- GOSUB GETMONTH
- EXIT SUB
-
- CHECKDATE:
- INVALID = 0
- DMM$ = MID$(DTE$, 1, 2): DDD$ = MID$(DTE$, 3, 2): DYY$ = MID$(DTE$, 5, 2)
- DMM = VAL(DMM$): DYY = VAL(DYY$): DDD = VAL(DDD$)
- IF DDD < 1 OR DDD > 31 THEN INVALID = 1: RETURN
- IF (DMM = 4 OR DMM = 6 OR DMM = 9 OR DMM = 11) AND DDD > 30 THEN INVALID = 1: RETURN
- IF DYY <= 80 THEN INVALID = 1: RETURN
- IF DMM <> 2 THEN RETURN
- IF DDD > 29 THEN INVALID = 1: RETURN
- IF ((DYY MOD 4) <> 0) AND DDD > 28 THEN INVALID = 1: RETURN
-
- GETMONTH:
- MON$ = LEFT$(DTE$, 2)
- CURRMON = VAL(MON$)
- MONTH$ = MO$(CURRMON)
- DAY$ = STR$(VAL(MID$(DTE$, 3, 2))): YEAR$ = "19" + RIGHT$(DTE$, 2)
- CurrDate$ = MONTH$ + DAY$ + ", " + YEAR$
- CURRDAY = VAL(DAY$)
- CURRYEAR = VAL(MID$(YEAR$, 3, 2))
- RETURN
-
- END SUB
-
- DEFSNG A-Z
- REM $DYNAMIC
- DEFINT A-Z
- DEFINT A-Z
- REM $DYNAMIC
- SUB NewClear (COLR1, COLR2)
- CALL PUTSTRNG(0, 0, 2000, COLR1 + COLR2 + 16, STRING$(2000, 177))
- END SUB
-
-